package simple.form.controller;

import com.alibaba.fastjson.JSONObject;
import simple.form.controller.interceptor.Interceptor;
import simple.form.controller.interceptor.RequestLogInterceptor;
import simple.form.dao.MysqlCreator;
import simple.form.dao.SqlCreator;
import simple.form.dao.Table;
import simple.form.db.AbsDataSource;
import simple.form.db.DefaultDataSource;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2017/2/23.
 */
public class SysContent {
    /*控制器*/
    public static Map<String,Object> controller = new HashMap<>();
    /*控制器的url映射 Map<"url","对应的控制器名称">*/
    public static Map<String,String> requestMappingController = new HashMap<>();
    /*控制器的url Method映射Map<"url","方法">*/
    public static Map<String,Method> requestMappingMethod = new HashMap<>();
    /*控制器的url 缓存key映射 Map<"url","缓存key类型">*/
    public static Map<String,Class> requestMappingCacheKey = new HashMap<>();
    /*controller包路径*/
    public static String controllerPackageName;
    /*表单bean包路径*/
    public static String formBeanPackageName;

    /*拦截器,默认添加日志请求拦截器*/
    public static List<Interceptor> interceptors = new ArrayList<Interceptor>(){{
        add(new RequestLogInterceptor());
    }};


    /*service包路径*/
    public static String servicePackageName;
    /*控制器的Service,Map<"控制器的类名,List<Service>">*/
    public static Map<String,List<Object>> controllersService = new HashMap<>();
    /*控制器的Service,Map<"Service类名,List<DAO>">*/
    public static Map<String,List<Object>> servicesDao = new HashMap<>();
    /*services,Map<"service名称","service实例">*/
    public static Map<String,Object> services = new HashMap<>();




    /*数据源*/
//    public static AbsDataSource dataSource = new DefaultDataSource(new JSONObject(){{
//        put("url","jdbc:mysql://127.0.0.1:3306/simpleForm?useUnicode=true&characterEncoding=utf-8");
//        put("user_name","root");
//        put("pass_word","root");
//        put("driver","com.mysql.jdbc.Driver");
//    }});

    /*数据源*/
    public static AbsDataSource dataSource;
    /*orm bean包路径*/
    public static String ormPackageName;
    /*bean类与数据库表分映射关系,Map<"bean的class name","bean的table name">*/
    public static Map<String,Table> beansMappingTables = new HashMap<>();
    /*sql创建器*/
    public static SqlCreator sqlCreator = new MysqlCreator();
    /*dao层的包路径*/
    public static String daoPackageName;

    /*services,Map<"dao名称","dao实例">*/
    public static Map<String,Object> daos = new HashMap<>();
}
